package com.vue.mapper;


import com.github.pagehelper.Page;
import com.vue.annotation.AutoFill;
import com.vue.dto.CoursePageQueryDTO;
import com.vue.entity.Course;
import com.vue.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface CourseMapper {

    /**
     * 课程分页查询
     * @param coursePageQueryDTO
     * @return
     */
    Page<Course> PageQuery(CoursePageQueryDTO coursePageQueryDTO);

    /**
     * 修改课程
     * @param course
     */
    @AutoFill(OperationType.UPDATE)
    void update(Course course);

    /**
     * 新增课程
     * @param course
     */
    @AutoFill(OperationType.INSERT)
    @Insert("insert into course(name, course_code, t_id, teacher, create_time, update_time) " +
            "values (#{name},#{courseCode},#{tId},#{teacher},#{createTime},#{updateTime})")
    void insert(Course course);

    /**
     * 根据id删除课程
     * @param id
     */
    @Delete("delete from course where id = #{id}")
    void deleteById(Long id);
}
